/*
 * fastaAlg.h
 *
 *  Created on: 30-09-2011
 *      Author: pawel
 */

#ifndef FASTAALG_H_
#define FASTAALG_H_
#include"heurAlgV.h"
#include"fastaAlgParam.h"
#include<boost/unordered_map.hpp>
#include"../smart2DArray.h"
#include<ext/slist>
//#include<string>
struct optAlgThreadParam;
namespace bpp{
 class BasicSequence;
}
struct bounds;
/**
 * This class implements FASTA algorithm
 */
class fastaAlg :public heurAlgV{
private:
	/*
	 * Algorithm parameters
	 */
	fastaAlgParam fastaParam;
	/*
	 * map of k words in query sequence
	 */
	boost::unordered_multimap<std::string,int> queryKTouples;
	/*
	 * Query sequence length
	 */
	size_t qLength;
	/*
	 * Letters of query string
	 */
	smart2DArray<char> smartQueryString;
	/*
	 * numerical symbols of letters
	 */
	smart2DArray<int> smartQueryContent;
	/*
	 * Start fasta algorithm thread
	 */
	void* runThread();
	/*
	 * Return list of 10 best scored diagonals
	 */
	__gnu_cxx::slist<diagonal> computeDiagonalHits(bpp::BasicSequence *dbSeqPtr);
	/*
	 * Rescore diagonals using score matrix
	 */
	int rescoreDiagonals(__gnu_cxx::slist<diagonal> &list,bpp::BasicSequence *dbSeqPtr);
	/*
	 * Compute bounds of dynamic programming matrix
	 */
	bounds computeBounds(__gnu_cxx::slist<diagonal> &list);
public:
	/*
	 * Constructor
	 */
	fastaAlg(const optAlgThreadParam &optAlgParam,size_t heurThreads,size_t optThreads,const fastaAlgParam &fastaParam);
	~fastaAlg();
	/*
	 * Run algorithm
	 */
	void runAlg();
};




#endif /* FASTAALG_H_ */
